package
{
	import custom_event.NavigationEvent;
	
	import starling.display.Sprite;
	import starling.events.Event;
		
	public class Game extends Sprite
	{
		public function Game()
		{
			super()
			this.addEventListener(starling.events.Event.ADDED_TO_STAGE, onAddedToStage);
		}
		
		private var intro:IntroSplashScreen;
		private var ingame:InGameScreen;
		private var menu:MainMenuScreen;
		
		private function onAddedToStage(event:Event):void {
			this.addEventListener(custom_event.NavigationEvent.CHANGE_SCREEN, onChangeScreen);
			
			intro=new IntroSplashScreen()
			ingame = new InGameScreen();
			menu = new MainMenuScreen();
			
			this.addChild(intro);
			this.addChild(ingame);
			this.addChild(menu);
			
			ingame.off();
			menu.off();
			
		}
		
		private function onChangeScreen(event:NavigationEvent):void
		{
			switch(event.data.id) {
				case "go to main menu":
					intro.off();
					ingame.off();
					menu.on();
					break;
				case "go to intro":
					intro.on();
					ingame.off();
					menu.on();
					break;
				case "play":
					intro.off();
					ingame.on();
					menu.off();
				default:
					break;
			}
			
		}
	}
}